package com.wlys.player.ui.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import com.wlys.player.R;
import com.wlys.player.ui.adapter.TrackAdapter;
import com.wlys.player.ui.asynctask.TrackTask;

public class TrackAllActivity extends Activity
{

    ListView mListView;
    TrackAdapter mTrackAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_track_all);
        findViewById();
        setListener();
        mTrackAdapter = new TrackAdapter(this);
        mListView.setAdapter(mTrackAdapter);
        new TrackTask(this,mTrackAdapter).execute();
    }

    private void findViewById()
    {
        mListView = (ListView) findViewById(R.id.track_listview);
    }

    private void setListener()
    {
        mListView.setOnItemClickListener(new OnItemClickListener()
        {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id)
            {
                PlayTrackActivity.launch(mTrackAdapter.getItem(position),TrackAllActivity.this);
            }
        });
    }

}